package com.mqz.zebraEcommerce.commodity.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.mqz.zebraEcommerce.common.valid.*;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 商品品牌表
 *
 * @author mqz
 * @email 952905931@qq.com
 * @date 2025-02-27 11:07:19
 */
@Data
@TableName("commodity_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId
    @Null(message = "id为自动生成，无需指定", groups = SaveGroup.class)
    @NotNull(message = "id不能为空", groups = {UpdateGroup.class, UpdateIsShowGroup.class})
    private Long id;
    /**
     * 名称
     */
    @NotBlank(message = "名称不能为空", groups = {SaveGroup.class, UpdateGroup.class})
    private String name;
    /**
     * logo
     */
    @NotBlank(message = "logo不能为空", groups = {SaveGroup.class})
    @URL(message = "不是一个合法的URL", groups = {SaveGroup.class, UpdateGroup.class})
    private String logo;
    /**
     * 说明
     */
    @NotBlank(message = "说明不能为空", groups = {SaveGroup.class, UpdateGroup.class})
    private String description;
    /**
     * 0不显示，1显示
     */
    @NotNull(message = "显示状态值不能为空", groups = {SaveGroup.class, UpdateIsShowGroup.class})
//    @EnumValidate(values = {0, 1}, message = "显示状态值必须为0或1", groups = {SaveGroup.class, UpdateGroup.class})
    @IsShowValidate(regexp = "^[0-1]$", message = "显示状态值必须为0或1", groups = {SaveGroup.class, UpdateGroup.class, UpdateIsShowGroup.class})
    private Integer isShow;
    /**
     * 检索首字母
     */
    @NotBlank(message = "检索首字母不能为空", groups = {SaveGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^[A-Z]$", message = "检索首字母必须在A-Z之间", groups = {SaveGroup.class, UpdateGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    @NotNull(message = "排序值不能为空", groups = {SaveGroup.class})
    @Min(value = 0, message = "排序必须为非负整数", groups = {SaveGroup.class, UpdateGroup.class})
    @SortValidate(regexp = "^(0|[1-9]\\d*)$", message = "排序值必须为非负整数", groups = {SaveGroup.class, UpdateGroup.class})
    private Integer sort;

}
